/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package co.com.entidad;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author 841756
 */
@Entity
@Table(name = "tbl_usuario")
@NamedQueries({
    @NamedQuery(name = "TblUsuario.findAll", query = "SELECT t FROM TblUsuario t"),
    @NamedQuery(name = "TblUsuario.findByUsuario", query = "SELECT t FROM TblUsuario t WHERE t.usuario = :usuario"),
    @NamedQuery(name = "TblUsuario.findByContrasena", query = "SELECT t FROM TblUsuario t WHERE t.contrasena = :contrasena"),
    @NamedQuery(name = "TblUsuario.findByUsuarioLogin", query = "SELECT t FROM TblUsuario t WHERE t.usuario = :usuario and t.contrasena = :contrasena"),
    @NamedQuery(name = "TblUsuario.findByCorreo", query = "SELECT t FROM TblUsuario t WHERE t.correo = :correo"),
    @NamedQuery(name = "TblUsuario.findByNroIntentos", query = "SELECT t FROM TblUsuario t WHERE t.nroIntentos = :nroIntentos")})
public class TblUsuario implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "usuario")
    private String usuario;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "contrasena")
    private String contrasena;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "correo")
    private String correo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "nro_intentos")
    private long nroIntentos;
    @JoinColumn(name = "cod_rol", referencedColumnName = "cod_rol")
    @ManyToOne(optional = false)
    private Tblroles codRol;
    @JoinColumn(name = "cod_compania", referencedColumnName = "cod_compania")
    @ManyToOne(optional = false)
    private Tblcompania codCompania;
    @JoinColumn(name = "id_estado", referencedColumnName = "id_estado")
    @ManyToOne(optional = false)
    private TblEstado idEstado;

    public TblUsuario() {
    }

    public TblUsuario(String usuario) {
        this.usuario = usuario;
    }

    public TblUsuario(String usuario, String contrasena, String correo, long nroIntentos) {
        this.usuario = usuario;
        this.contrasena = contrasena;
        this.correo = correo;
        this.nroIntentos = nroIntentos;
    }

    public String getUsuario() {
        return usuario;
    }

    public void setUsuario(String usuario) {
        this.usuario = usuario;
    }

    public String getContrasena() {
        return contrasena;
    }

    public void setContrasena(String contrasena) {
        this.contrasena = contrasena;
    }

    public String getCorreo() {
        return correo;
    }

    public void setCorreo(String correo) {
        this.correo = correo;
    }

    public long getNroIntentos() {
        return nroIntentos;
    }

    public void setNroIntentos(long nroIntentos) {
        this.nroIntentos = nroIntentos;
    }

    public Tblroles getCodRol() {
        return codRol;
    }

    public void setCodRol(Tblroles codRol) {
        this.codRol = codRol;
    }

    public Tblcompania getCodCompania() {
        return codCompania;
    }

    public void setCodCompania(Tblcompania codCompania) {
        this.codCompania = codCompania;
    }

    public TblEstado getIdEstado() {
        return idEstado;
    }

    public void setIdEstado(TblEstado idEstado) {
        this.idEstado = idEstado;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (usuario != null ? usuario.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblUsuario)) {
            return false;
        }
        TblUsuario other = (TblUsuario) object;
        if ((this.usuario == null && other.usuario != null) || (this.usuario != null && !this.usuario.equals(other.usuario))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "" + usuario + "";
    }

}
